﻿Imports System.Data.SqlClient
Imports System.Configuration

Public Class DALSQLServer

    Private Shared _instancia As DALSQLServer
    Private _cadenaConexion As String

    Private _conexion As IDbConnection
    Public ReadOnly Property Conexion() As IDbConnection
        Get            
            Return _conexion
        End Get
    End Property

    Sub New()
        _cadenaConexion = System.Configuration.ConfigurationManager.ConnectionStrings("Testeitor").ConnectionString    
        _conexion = New SqlConnection(_cadenaConexion)
    End Sub

    Public Shared Function Instancia() As DALSQLServer
        'Inicializo si no esta en uso
        If _instancia Is Nothing Then
            _instancia = New DALSQLServer
        End If
        'Retorno la instancia inicializada como un Singleton
        Return _instancia
    End Function

End Class
